class EntriesController < ApplicationController
   
  layout 'entries'
  
  before_filter :set_per_page, :set_ancillaries
  
  def index
  	@articles = current_lough.request_pagination_articles(params)
  end
  
  attr_reader :recent_entries

  def show
  	@article = current_lough.request_article(params)
  end
  
  protected
  
  def set_per_page
  	Article.per_page = current_lough.article_per_page
  end
  
  def set_ancillaries
  	@recent_entries = current_lough.request_recent_articles()
  	@archives = archives_list()
  end
  
  def archives_list(count = 8)
    archives = []
    year, month = Time.now.year, Time.now.month
    count.times do |i|
      archives << Time.utc(year, month)
      month -= 1
      if month == 0
      	year -= 1
      	month = 12
      end
    end
    archives
  end
  
end

